package com.idc.resource.controller;

import com.idc.resource.model.FileTest;
import com.idc.resource.util.FileBase64Util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 文件上传测试
 * Created by Lijing on 2017/7/12.
 */
@Slf4j
@RestController
@RequestMapping(value = "/file")
public class FileTestController {

    @RequestMapping(value = "/upload", method = RequestMethod.POST)
    public String fileUpload(FileTest fileTest){
        log.info("{}",fileTest);
        MultipartFile file = fileTest.getFileOne();
        try {
            byte[] bytes  =  file.getBytes();
            String base = FileBase64Util.getBase64(bytes);
        } catch (IOException e) {
            e.printStackTrace();
        }


        return "........";
    }
}
